﻿using Microsoft.Phone.Tasks;
using Q42.WinRT.Data;
using SpaceNeedle.SDK.Windows.Platform.Commands;
using SpaceNeedle.SDK.Windows.Platform.Data;
using SpaceNeedle.x6473.WindowsPhone.Common;
using SpaceNeedle.x6473.WindowsPhone.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace SpaceNeedle.x6473.WindowsPhone.ViewModels
{
    public class AboutViewModel : GlobalViewModel
    {
        public AboutViewModel() :base()
        {
            this.MoreInfoCommand = new RelayCommand(MoreInfo);
        }

        public AppContent StaticAppContent
        {
            get { return this.Get<AppContent>(); }
            set { this.Set(value); }
        }

        public AppContent.AboutInfo StaticContent
        {
            get { return this.Get<AppContent.AboutInfo>(); }
            set { this.Set(value); }
        }

        public string PageTitle
        {
            get { return this.Get<string>(); }
            set { this.Set(value); }
        }

        public string Content
        {
            get { return this.Get<string>(); }
            set { this.Set(value); }
        }

        public ICommand MoreInfoCommand { get; set; }

        private void MoreInfo(object param)
        {
            string uri = StaticContent.AboutKnowMoreButtonUri;
            
            WebBrowserTask task = new WebBrowserTask();
            task.Uri = new Uri(uri, UriKind.RelativeOrAbsolute);
            task.Show();
        }

        protected async override void Load()
        {
            this.IsInProgress = true;

            await base.LoadAsync();

            this.StaticContent = this.AppContent.About;
            this.StaticAppContent = this.AppContent;

            Tracking.SendView(ViewsNames.About);

            this.IsInProgress = false;
        }
    }
}
